<?php
/**
 * Created by PhpStorm.
 * User: yzapple
 * Date: 2018/1/10
 * Time: 上午9:44
 */
namespace app\common\model;
use app\common\model\Base;
use think\Db;

class User extends Base
{
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;
    // 定义时间戳字段名
    protected $table = "user";

    public static  function getByMobile($mobile)
    {
        $item = self::get(['phone' => $mobile]);
        return $item ? $item->phone : '';
    }


    public $base_arr = [
        'table' => 'user',
        'field' => 'name,password,phone,sex',
        'primary_key' => 'id'
    ];

    public $attach_arr = [


    ];

    //预计一维数组
    protected $senMsgAttach = [

        'table' => 'user',
        'field' => 'phone',
        'primary_key' => 'id',

    ];

    /**
     * 获取字段对应的数组
     * */
    public function getDataByMysql()
    {
        $data = [
            't_name' => $this->table,//必填
            'model' => '用户',//必填
            'name' => '用户名',
            'phone'=>'手机号',
            'sex'=>'性别',
            'password' => '密码',
            'is_deleted' => '{"2":"功能禁用","1":"功能启用","3":"功能删除"}'
        ];
        return $data;
    }

    public static function sendMsgToUser($record_ids){
        //获取当前数据操作问题
        $model = new User();
        $sendMsgName = Base::getOneFieldByTablesToSendMsg($record_ids,$model->base_arr,$model->senMsgAttach);
        // print_r($sendMsgName);
        return $sendMsgName;
    }
}